/**
 * Created by jean.h.ma on 15/04/2018.
 */
import React from 'react'
import Base from '@codefree/badger/app/components/Base'
import axios from 'axios'
import {DataTable, DataTableWithPagination} from 'react-component-data-table'
import {Link} from 'react-router-dom'
import PropTypes from 'prop-types'
import Master from '../../components/Master'


export default class ScheduleList extends Base {
    constructor(props) {
		super(props);
		this.state = {
            id:null,
			schedule_start: null,
            schedule_end: null,
            test_dline: null,
            prac_dline: null,
            fillSource:[],
            judgeSource:[],
            selectionSource:[],
            applicationSource:[],
            calculationSource:[],
            classSource:[],
            classNum:null,
            majorNowNum:this.props.history.location.search.substr(4),
            defaultFill:['1','1','1'],
            defaultJudge:['1','1','1'],
            defaultSelection:['1','1','1'],
            defaultCalculation:['1','1','1'],
            defaultApplication:['1','1','1','1','1','1','1'],
            point:[],
            methodologe:[],
            difficulty:[],
            fillRowScore:null,
            fillTotalScore:null,
            judgeRowScore:null,
            judgeTotalScore:null,
            selectionRowScore:null,
            selectionTotalScore:null,
            calculationTotalScore:null,
            applicationTotalScore:null,

            
		
        };
        //this.handleChange = this.handleChange.bind(this);
        
        this.dataTableInstance = null;
        this.handleChange = this.handleChange.bind(this);
		this.columnFill = [{
			name: "序号",
			render: (rowData,rowDataIndex)=>rowDataIndex+1
             
		}, {
			name: "知识点",
			render: (rowData,rowDataIndex) => {
                return(
             
                    <select  onChange={event => {
                        this.updateState({
                            fillSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[event.target.value,oldArr[i][1],oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.fillSource[rowDataIndex][0]}>
                        {this.state.point.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
         
            }
		},{
            name: "难易度",
			render: (rowData,rowDataIndex) => {
                return (
                    <select onChange={event => {
                        this.updateState({
                            fillSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],event.target.value,oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.fillSource[rowDataIndex][1]}>
                        {this.state.difficulty.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                   
                )
            }
        },{
            name: "操作",
			render: (rowData, rowDataIndex) => {
				return (
                    <a href="javascript:void(0)" onClick={()=>{
                  
                        this.updateState({
                            fillSource:{$splice:[[rowDataIndex,1]]},
                            fillTotalScore:{$set:parseInt(this.state.fillTotalScore)-parseInt(this.state.fillRowScore)}
                        })
                    }}>删除</a>
				);
			}
        }];
        this.columnSelection = [{
			name: "序号",
			render: (rowData,rowDataIndex) => rowDataIndex+1
		}, {
			name: "知识点",
			render: (rowData,rowDataIndex) =>{
                return (
                    <select  onChange={event => {
                        this.updateState({
                            selectionSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[event.target.value,oldArr[i][1],oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        
                        }} value={this.state.selectionSource[rowDataIndex][0]}>
                        {this.state.point.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            }
		},{
            name: "难易度",
			render: (rowData,rowDataIndex) => {               
                return (
                    <select onChange={event => {
                        this.updateState({
                            selectionSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],event.target.value,oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.selectionSource[rowDataIndex][1]}>
                        {this.state.difficulty.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            }
        },{
            name: "操作",
			render: (rowData,rowDataIndex) => {
				return (
					<a href="javascript:void(0)" onClick={()=>{
                        this.updateState({
                            selectionSource:{$splice:[[rowDataIndex,1]]},
                            selectionTotalScore:{$set:parseInt(this.state.selectionTotalScore)-parseInt(this.state.selectionRowScore)}
                        })
                    }}>删除</a>
				);
			}
        }];
        this.columnJudge = [{
			name: "序号",
			render: (rowData,rowDataIndex) => rowDataIndex+1
		}, {
			name: "知识点",
			render: (rowData,rowDataIndex) => {
                return (
                    <select  onChange={event => {
                       
                        this.updateState({
                            judgeSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[event.target.value,oldArr[i][1],oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.judgeSource[rowDataIndex][0]}>
                        {this.state.point.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            }
		},{
            name: "难易度",
			render: (rowData,rowDataIndex) => {
              
                return (
                    <select onChange={event => {
                        this.updateState({
                            judgeSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],event.target.value,oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.judgeSource[rowDataIndex][1]}>
                        {this.state.difficulty.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            }
        },{
            name: "操作",
			render: (rowData,rowDataIndex) => {
				return (
					<a href="javascript:void(0)" onClick={()=>{
                        this.updateState({
                            judgeSource:{$splice:[[rowDataIndex,1]]},
                            judgeTotalScore:{$set:parseInt(this.state.judgeTotalScore)-parseInt(this.state.judgeRowScore)}

                        })
                    }}>删除</a>
				);
			}
        }];
        this.columnCalculation = [{
			name: "序号",
			render: (rowData,rowDataIndex) => rowDataIndex+1
		}, {
			name: "方法论",
			render: (rowData,rowDataIndex) =>  {
                
                return (
                    <select onChange={event => {
                            this.updateState({
                                calculationSource:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                        if(i==rowDataIndex){
                                            newArr[i]=[event.target.value,oldArr[i][1],oldArr[i][2]];
                                        }else{
                                            newArr[i]=oldArr[i];
                                        }
                                    }
                                    return newArr;

                                }}

                            })
                        }} value={this.state.calculationSource[rowDataIndex][0]}>
                        {this.state.methodologe.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            } 
		},{
            name: "难易度",
			render: (rowData,rowDataIndex) => {
          
                
                return (
                    <select onChange={event => {
                        this.updateState({
                            calculationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],event.target.value,oldArr[i][2]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.calculationSource[rowDataIndex][1]}>
                        {this.state.difficulty.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            }
        },{
            name: "分值",
			render: (rowData,rowDataIndex) => {
                return(
                    <input type="text" 
                    style={{width: 50}} 
                    
                    onChange={event=>{
                        if(event.target.value==''){
                            event.target.value='0';
                        }
                        this.updateState({
                            calculationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],oldArr[i][1],event.target.value];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }},
                            
                            calculationTotalScore:{$set:parseInt(this.state.calculationTotalScore)-parseInt(this.state.calculationSource[rowDataIndex][2])+parseInt(event.target.value)}

                        })
                        

                    }}
                    value={this.state.calculationSource[rowDataIndex][2]}  />
                )
            }
        },{
            name: "操作",
			render: (rowData,rowDataIndex) => {
				return (
					<a href="javascript:void(0)" onClick={()=>{
                        this.updateState({
                            calculationSource:{$splice:[[rowDataIndex,1]]},
                            calculationTotalScore:{$set:parseInt(this.state.calculationTotalScore)-parseInt(this.state.calculationSource[rowDataIndex][2])}

                        })
                    }}>删除</a>
				);
			}
        }];
        this.columnApplication = [{
			name: "序号",
			render: (rowData,rowDataIndex) => rowDataIndex+1
		}, {
			name: "方法论",
			render: (rowData,rowDataIndex) => {
                return (
                    <select onChange={event => {
                            this.updateState({
                                applicationSource:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                        if(i==rowDataIndex){
                                            newArr[i]=[event.target.value,oldArr[i][1],oldArr[i][2],oldArr[i][3],oldArr[i][4],oldArr[i][5],oldArr[i][6]];
                                        }else{
                                            newArr[i]=oldArr[i];
                                        }
                                    }
                                    return newArr;

                                }}

                            })
                        }} value={this.state.applicationSource[rowDataIndex][0]}>
                        {this.state.methodologe.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
                
            } 
		},{
            name: "难易度",
            render: (rowData,rowDataIndex) => {
          
                
                return (
                    <select onChange={event => {
                        this.updateState({
                            applicationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],event.target.value,oldArr[i][2],oldArr[i][3],oldArr[i][4],oldArr[i][5],oldArr[i][6]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }}

                        })
                        }} value={this.state.applicationSource[rowDataIndex][1]}>
                        {this.state.difficulty.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.name}</option>
                            )
                        })}
                    </select>
                )
            }
			
        },{
            name: "变量",
			render: (rowData,rowDataIndex) => {
                return(
                    <input type="text" 
                    style={{width: 50}} 
                    
                    onChange={event=>{
                        if(event.target.value==''){
                            event.target.value='0';
                        }
                        this.updateState({
                            applicationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],oldArr[i][1],event.target.value,oldArr[i][3],oldArr[i][4],oldArr[i][5],oldArr[i][6]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }},
                            applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)-parseInt(this.state.applicationSource[rowDataIndex][2])+parseInt(event.target.value)}

                        })

                    }}
                    value={this.state.applicationSource[rowDataIndex][2]} />
                )
            } 
        },{
            name: "目标函数",
			render: (rowData,rowDataIndex) => {
                return(
                    <input type="text" 
                    style={{width: 50}} 
                    
                    onChange={event=>{
                        if(event.target.value==''){
                            event.target.value='0';
                        }
                        this.updateState({
                            applicationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],oldArr[i][1],oldArr[i][2],event.target.value,oldArr[i][4],oldArr[i][5],oldArr[i][6]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }},
                            applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)-parseInt(this.state.applicationSource[rowDataIndex][3])+parseInt(event.target.value)}

                        })

                    }}
                    value={this.state.applicationSource[rowDataIndex][3]}  />
                )
            } 
        },{
            name: "约束条件",
			render: (rowData,rowDataIndex) => {
                return(
                    <input type="text" 
                    style={{width: 50}} 
                    
                    onChange={event=>{
                        if(event.target.value==''){
                            event.target.value='0';
                        }
                        this.updateState({
                            applicationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],oldArr[i][1],oldArr[i][2],oldArr[i][3],event.target.value,oldArr[i][5],oldArr[i][6]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }},
                            applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)-parseInt(this.state.applicationSource[rowDataIndex][4])+parseInt(event.target.value)}

                        })

                    }}
                    value={this.state.applicationSource[rowDataIndex][4]}  />
                )
            } 
        },{
            name: "最优解",
			render: (rowData,rowDataIndex) => {
                return(
                    <input type="text" 
                    style={{width: 50}} 
                    
                    onChange={event=>{
                        if(event.target.value==''){
                            event.target.value='0';
                        }
                        this.updateState({
                            applicationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],oldArr[i][1],oldArr[i][2],oldArr[i][3],oldArr[i][4],event.target.value,oldArr[i][6]];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }},
                            applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)-parseInt(this.state.applicationSource[rowDataIndex][5])+parseInt(event.target.value)}

                        })

                    }}
                    value={this.state.applicationSource[rowDataIndex][5]}  />
                )
            } 
        },{
            name: "计算文件",
			render: (rowData,rowDataIndex) => {
                return(
                    <input type="text" 
                    style={{width: 50}} 
                    
                    onChange={event=>{
                        if(event.target.value==''){
                            event.target.value='0';
                        }
                        this.updateState({
                            applicationSource:{$apply:oldArr=>{
                                let newArr=new Array();
                                for(let i=0;i<oldArr.length;i++){
                                    if(i==rowDataIndex){
                                        newArr[i]=[oldArr[i][0],oldArr[i][1],oldArr[i][2],oldArr[i][3],oldArr[i][4],oldArr[i][5],event.target.value];
                                    }else{
                                        newArr[i]=oldArr[i];
                                    }
                                }
                                return newArr;

                            }},
                            applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)-parseInt(this.state.applicationSource[rowDataIndex][6])+parseInt(event.target.value)}

                        })

                    }}
                    value={this.state.applicationSource[rowDataIndex][6]}  />
                )
            } 
        },{
            name: "操作",
			render: (rowData,rowDataIndex) => {
				return (
					<a href="javascript:void(0)" onClick={()=>{
                        this.updateState({
                            applicationSource:{$splice:[[rowDataIndex,1]]},
                            applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)-parseInt(this.state.applicationSource[rowDataIndex][2])-parseInt(this.state.applicationSource[rowDataIndex][3])-parseInt(this.state.applicationSource[rowDataIndex][4])-parseInt(this.state.applicationSource[rowDataIndex][5])-parseInt(this.state.applicationSource[rowDataIndex][6])}

                        })
                    }}>删除</a>
				);
			}
        }];
    }
    handleChange(event){
        this.setState({value: event.target.majorNowNum})
    };

    async classList(){
        const {data} = await axios.get(`http://127.0.0.1:3000/schedule/queryClass`);
		if (data.code === 0) {
			this.updateState({
                classSource: {$set: data.data.list},
          
            });
	
		}		
		else {
			alert(data.message);
		}
    }
    
    async scoreList(filter){
     //  console.log(this.state.majorNowNum);
		const {data} = await axios.post(`http://127.0.0.1:3000/schedule/queryScore`,{
            id:this.state.majorNowNum,
        });
		if (data.code === 0) {
			this.updateState({
                schedule_start: {$set: data.data.list[0].schedule_start},
                schedule_end: {$set: data.data.list[0].schedule_end},
                test_dline: {$set: data.data.list[0].test_dline},
                prac_dline: {$set: data.data.list[0].prac_dline},
                fillSource: {$set: data.data.list[0].schedule_scores[0]},
                judgeSource: {$set: data.data.list[0].schedule_scores[1]},
                selectionSource: {$set: data.data.list[0].schedule_scores[2]},
                calculationSource: {$set: data.data.list[0].schedule_scores[3]},
                applicationSource: {$set: data.data.list[0].schedule_scores[4]},
                majorNowNum: {$set:data.data.list[0].major_id},
                fillRowScore:{$set:data.data.list[0].fillRowScore},
                judgeRowScore:{$set:data.data.list[0].judgeRowScore},
                selectionRowScore:{$set:data.data.list[0].selectionRowScore},
                fillTotalScore:{$set:data.data.list[0].fillCountScore},
                judgeTotalScore:{$set:data.data.list[0].judgeCountScore},
                selectionTotalScore:{$set:data.data.list[0].selectionCountScore},
                calculationTotalScore:{$set:data.data.list[0].calculationCountScore},
                applicationTotalScore:{$set:data.data.list[0].applicationCountScore},
            });
        
        }        
		else {
			alert(data.message);
		}
    }
    async pointList(){
        const {data} = await axios.get(`http://127.0.0.1:3000/schedule/queryPoint`);
		if (data.code === 0) {
			this.updateState({
                point: {$set: data.data},
                
            });
    
        }        
		else {
			alert(data.message);
		}
      
        
       
    }
    async methodologeList(){
        const {data} = await axios.get(`http://127.0.0.1:3000/schedule/queryMethodologe`);
		if (data.code === 0) {
			this.updateState({
                methodologe: {$set: data.data},
                
            });
    
        }        
		else {
			alert(data.message);
		}
      
       
    }
    async difficultyList(){
        const {data} = await axios.get(`http://127.0.0.1:3000/schedule/queryDifficulty`);
		if (data.code === 0) {
			this.updateState({
                difficulty: {$set: data.data},
                
            });
    
        }        
		else {
			alert(data.message);
		}
       
       
    }
    async create() {
		const {data} = await axios.post(`http://127.0.0.1:3000/schedule/create`, {
            id:this.state.classNum,
            start:this.state.schedule_start,
            end:this.state.schedule_end,
            prac:this.state.prac_dline,
            test:this.state.test_dline,
            fillResult:this.state.fillSource,
            judgeResult:this.state.judgeSource,
            selectionResult:this.state.selectionSource,
            calculationResult:this.state.calculationSource,
            applicationResult:this.state.applicationSource,
			
		});
		if (data.code === 0) {
			alert("添加成功");
			window.location.href="#/test/schedule";
		}
		else {
			alert(data.message);
		}
	}
    

    render(){
     
        const dataSource = [
            {考试开始时间: <input onChange={event=>{
                this.updateState({              
                    schedule_start:{$set:event.target.value}
                })

            }} value={this.state.schedule_start} />,
             考试结束时间: <input  onChange={event=>{
                this.updateState({              
                    schedule_end:{$set:event.target.value}
                })

            }} value={this.state.schedule_end} />, 
             练习有效期: <input  onChange={event=>{
                this.updateState({              
                    prac_dline:{$set:event.target.value}
                })

            }} value={this.state.prac_dline} />,
             测试有效期: <input  onChange={event=>{
                this.updateState({              
                    test_dline:{$set:event.target.value}
                })

            }} value={this.state.test_dline} />},
		
		];
		const columns = [
			{name: "考试开始时间", render: rowData => rowData['考试开始时间']},
            {name: "考试结束时间", render: rowData => rowData['考试结束时间']},
            {name: "练习有效期", render: rowData => rowData['练习有效期']},
            {name: "测试有效期", render: rowData => rowData['测试有效期']},
        ];
     

        return(
            <Master>
                <div>
                    
                    <label>复制</label>
                    <select 
                     onChange={event => {
                        this.updateState({
                            majorNowNum:{$set:event.target.value}
                        })
                    }} 
                    value={this.state.majorNowNum}>
                        {this.state.classSource.map((option,index)=>{
                            return(
                                <option key={index} value={option.id}>{option.major_name}</option>
                            )
                        })}
                    </select>
                    <button type="button" className="pure-button pure-button-primary"
                    onClick={this.scoreList.bind(this)} >确定</button>
                </div>
                <div>
                    <h2>时间设置</h2>
                    <DataTable columns={columns}
                            className="pure-table"
                            dataSource={dataSource}></DataTable>
                </div>
                <div>
                    <h2>填空题设置，每题<input type="text" style={{width: 50}} 
                        onChange={event=>{
                            if(event.target.value==''){
                                event.target.value='0';
                            }
                            this.updateState({
                                fillSource:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                  
                                            newArr[i]=[oldArr[i][0],oldArr[i][1],event.target.value];
                                    
                                    }
                                    return newArr;
    
                                }},
                                defaultFill:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                        if(i==2){
                                            newArr[i]=event.target.value;
                                        }else{
                                            newArr[i]= oldArr[i];
                                        }
                                          
                                    }
                                    return newArr;
    
                                }},
                                fillRowScore:{$set:event.target.value},
                                fillTotalScore:{$set:this.state.fillSource.length*event.target.value}
    
                            })
    
                        }}
                        value={this.state.fillRowScore} 
                    />分，合计<span>{this.state.fillTotalScore}</span>分
                    <button type="button" className="pure-button pure-button-primary button-xsmall"
                        onClick={(event) => {
                                const value = this.state.defaultFill;
                                this.updateState({
                                    fillSource: {$push: [value]},
                                    fillTotalScore:{$set:parseInt(this.state.fillTotalScore)+parseInt(this.state.fillRowScore)}
                                });
                          
                        }}>添加</button>
                    </h2>
                    
                    <DataTable columns={this.columnFill}
                                
                                className="pure-table"
                                dataSource={this.state.fillSource}></DataTable>
                </div>
                <div>
                    <h2>判断题设置，每题<input type="text" style={{width: 50}} 
                        onChange={event=>{
                            if(event.target.value==''){
                                event.target.value='0';
                            }
                            this.updateState({
                                judgeSource:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                  
                                            newArr[i]=[oldArr[i][0],oldArr[i][1],event.target.value];
                                    
                                    }
                                    return newArr;
    
                                }},
                                defaultJudge:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                        if(i==2){
                                            newArr[i]=event.target.value;
                                        }else{
                                            newArr[i]= oldArr[i];
                                        }
                                          
                                    }
                                    return newArr;
    
                                }},
                                judgeRowScore:{$set:event.target.value},
                                judgeTotalScore:{$set:this.state.judgeSource.length*event.target.value}
    
                            })
    
                        }}
                        value={this.state.judgeRowScore} 
                    />分，合计<span>{this.state.judgeTotalScore}</span>分
                    <button type="button" className="pure-button pure-button-primary button-xsmall"
                        onClick={(event) => {
                                const value = this.state.defaultJudge;
                                this.updateState({
                                    judgeSource: {$push: [value]},
                                    judgeTotalScore:{$set:parseInt(this.state.judgeTotalScore)+parseInt(this.state.judgeRowScore)}
                                });
                          
                        }}>添加</button>
                    </h2>
                    
                    <DataTable columns={this.columnJudge}
                            className="pure-table"
                            dataSource={this.state.judgeSource}></DataTable>
                </div>
                <div>
                    <h2>选择题设置，每题<input type="text" style={{width: 50}} 
                        onChange={event=>{
                            if(event.target.value==''){
                                event.target.value='0';
                            }
                            this.updateState({
                                selectionSource:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                  
                                            newArr[i]=[oldArr[i][0],oldArr[i][1],event.target.value];
                                    
                                    }
                                    return newArr;
    
                                }},
                                defaultSelection:{$apply:oldArr=>{
                                    let newArr=new Array();
                                    for(let i=0;i<oldArr.length;i++){
                                        if(i==2){
                                            newArr[i]=event.target.value;
                                        }else{
                                            newArr[i]= oldArr[i];
                                        }
                                          
                                    }
                                    return newArr;
    
                                }},
                                selectionRowScore:{$set:event.target.value},
                                selectionTotalScore:{$set:this.state.selectionSource.length*event.target.value}
    
                            })
    
                        }}
                        value={this.state.selectionRowScore} 
                    
                    />分，合计<span>{this.state.selectionTotalScore}</span>分
                    <button type="button" className="pure-button pure-button-primary button-xsmall"
                        onClick={(event) => {
                                const value = this.state.defaultSelection;
                                this.updateState({
                                    selectionSource: {$push: [value]},
                                    selectionTotalScore:{$set:parseInt(this.state.selectionTotalScore)+parseInt(this.state.selectionRowScore)}
                                });
                          
                        }}>添加</button>
                    </h2>
                    
                    <DataTable columns={this.columnSelection}
                            className="pure-table"
                            dataSource={this.state.selectionSource}></DataTable>
                </div>
                
                <div>
                    <h2>计算题设置，合计<span>{this.state.calculationTotalScore}</span>分
                    <button type="button" className="pure-button pure-button-primary button-xsmall"
                        onClick={(event) => {
                               // const value = this.state.defaultCalculation;
                               // console.log(value);
                                this.updateState({
                                    calculationSource: {$push: [this.state.defaultCalculation]},
                                    calculationTotalScore:{$set:parseInt(this.state.calculationTotalScore)+1}
                                });
                          
                        }}>添加</button>
                    </h2>
                    
                    <DataTable columns={this.columnCalculation}
                            className="pure-table"
                            dataSource={this.state.calculationSource}></DataTable>
                </div>
                <div>
                    <h2>应用题设置，合计<span>{this.state.applicationTotalScore}</span>分
                    <button type="button" className="pure-button pure-button-primary button-xsmall"
                        onClick={(event) => {
                                const value = this.state.defaultApplication;
                                this.updateState({
                                    applicationSource: {$push: [value]},
                                    applicationTotalScore:{$set:parseInt(this.state.applicationTotalScore)+5}
                                });
                          
                        }}>添加</button>
                    </h2>
                    
                    <DataTable columns={this.columnApplication}
                            className="pure-table"
                            dataSource={this.state.applicationSource}></DataTable>
                </div>
                <div>
                <br/><br/>
                <button type="button" className="pure-button pure-button-primary"
                onClick={this.create.bind(this)}
                
                >提交</button>
                <a href="#/test/schedule">
                <button type="button"   className="pure-button pure-button-primary button-margin-left">返回</button>
                </a>
                <br/><br/><br/><br/>
                </div>
            </Master>
        );
    }
    componentDidMount() {
        super.componentDidMount();
      //  let aa = queryString.parse(this.props.location.search);
        const urlQuery = this.props.location.search; // '?s=1&f=7'
      
        const successCount = urlQuery.substr(4);// '1'
        this.updateState({
            classNum: {$set: successCount},
        
        });
        
    
		this.classList({
			// pageIndex: this.state.pageIndex,
			// pageSize: this.state.pageSize
		});
		this.scoreList({
		
        });
        this.pointList({

        });
        this.methodologeList({

        });
        this.difficultyList({

        });
	}

}